import requests
from faker import Faker
faker = Faker(locale='zh_cn')
project_url = "http://60.205.190.66:8899"
response = requests.post(url = project_url+"/adminapi/login",json={"account": "admin", "pwd": "920509", "imgcode": "0"})
print(response.json())
token = response.json()['data']['token']
print(token)
# expires_time = response.json()['data']['expires_time']
# path =
print(response.status_code)
print(response.content)
print(response.text)

response1 = requests.get(project_url+"/adminapi/app/wechat/speechcraft",
                         json={"cate_id":"0", "title": "测试", "message": str(faker.name()), "sort": "1"},headers={"Authori-zation":"Bearer "+str(token)})
msg = response1.json()['msg']
print(response1.status_code)
print(response1.content)
print(response1.text)

response2 = requests.put(project_url+"/adminapi/app/wechat/speechcraft/"+str(id),
                                                                             json={"cate_id":"0", "title": "测试", "message": faker.name(), "sort": "2"},headers={"Authori-zation":"Bearer "+str(token)})
print(response2.status_code)
print(response2.content)
print(response2.text)



response3 = requests.get(project_url+"/adminapi/app/wechat/speechcraft?page=1&limit=15&cate_id",
                         json = {"id":0},headers={"Authori-zation":"Bearer "+str(token)})
for i in response2.json()['data']['list']:
    if i['message'] == str(name):
        self.id = i['id']
print(response3.status_code)
print(response3.content)
print(response3.text)

response4 = requests.delete(project_url+"/adminapi/app/wechat/speechcraft/"+str(id),headers={"Authori-zation":"Bearer "+str(token)})
print(response4.status_code)
print(response4.content)
print(response4.text)